package com.firstsource.networking.ip.tracker.data.entities;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Where;

@Entity
@Table(name="hosts")
public class Host implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Column(name="idx")
	@Id
	@GeneratedValue(generator="HostIndexSequence")
	@GenericGenerator(
				name="HostIndexSequence",
				strategy="seqhilo",
				parameters={
						@Parameter(name="max_lo", value="1"),
						@Parameter(name="sequence", value="host_idx_seq")
				}
			)
	private int idx = 0 ;

	@Column(name="hostname")
	private String hostname ;

	@Column(name="description")
	private String description = null ;

	@Column(name="notes",columnDefinition="TEXT")
	private String notes = null ;

	@OneToMany(mappedBy="host",fetch=FetchType.EAGER)
	private Set<Interface> InterfaceList = null ;

	@ManyToOne
	@JoinColumn(name="location_id")
	private Location location = null ;

	@ManyToOne
	@Where(clause="")
	private Subnet subnet = null ;

	/**
	 * @return the idx
	 */
	public int getIdx() {
		return idx;
	}

	/**
	 * @param idx the idx to set
	 */
	public void setIdx(int idx) {
		this.idx = idx;
	}

	/**
	 * @return the hostname
	 */
	public String getHostname() {
		return hostname;
	}

	/**
	 * @param hostname the hostname to set
	 */
	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	public void setInterfaceList(Set<Interface> interfaceList) {
		InterfaceList = interfaceList;
	}

	public Set<Interface> getInterfaceList() {
		return InterfaceList;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the notes
	 */
	public String getNotes() {
		return notes;
	}

	/**
	 * @param notes the notes to set
	 */
	public void setNotes(String notes) {
		this.notes = notes;
	}

	/**
	 * @return the location
	 */
	public Location getLocation() {
		return location;
	}

	/**
	 * @param location the location to set
	 */
	public void setLocation(Location location) {
		this.location = location;
	}

	public Subnet getSubnet() {
		return subnet;
	}

}
